using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using My.IdlConverter.Core.Util;
using My.IdlConverter.Core;
using My.IdlConverter.Core.Parsers;
using My.IdlConverter.Core.Types;
using My.IdlConverter.Com;

namespace My.IdlConverter.Analysis
{
    public class InterfaceAnalysis : Analysis
    {
        private string _odlIdlFile;
        private string _newIdlFile;

        public InterfaceAnalysis(string oldIdlFile, string newIdlFile)
        {
            _odlIdlFile = oldIdlFile;
            _newIdlFile = newIdlFile;
        }

        public override void DoAnalysis(IAnalysisReporter reporter) 
        {
            if (reporter == null)
                throw new ArgumentNullException("IAnalysisReporter reporter");

            IParser parser = new ComIdlParser();
            IList<Interface> oldInterfaceList = parser.Parse(_odlIdlFile) as IList<Interface>;
            IList<Interface> newInterfaceList = parser.Parse(_newIdlFile) as IList<Interface>;
            System.Diagnostics.Debug.Assert((oldInterfaceList != null) && (newInterfaceList != null));

            IInterfaceAnalysisReporter interfaceReporter = reporter as IInterfaceAnalysisReporter;
            interfaceReporter.Compare(oldInterfaceList, newInterfaceList);
            reporter.Report();
        }
    }
}
